<template>
  <div id="staffmanagement_container" style="height: 98%">
    <el-card>
      <div class="searchDiv">
        <div class="searchDivLeft">
          <span>部門名称: </span>
          <el-select v-model="staffmanagement.searchbean.departGuid" placeholder="" class="departGuid">
            <el-option v-for="item in optionData.value1[staffmanagement.searchbean.groupEnterpriseGuid]" :key="item.value" :label="item.name" :value="item.value"> </el-option>
          </el-select>
          &nbsp;
          <span>社員名前: </span>
          <el-input v-model="staffmanagement.searchbean.userName" placeholder="" class="userName"></el-input>
          &nbsp;
          <span>社員番号: </span>
          <el-input v-model="staffmanagement.searchbean.userNo" placeholder="" class="userNo"></el-input>
          &nbsp;
          <span>職務: </span>
          <el-select v-model="staffmanagement.searchbean.roleGuid" placeholder="" class="roleGuid">
            <el-option v-for="item in optionData.value2[staffmanagement.searchbean.groupEnterpriseGuid]" :key="item.value" :label="item.name" :value="item.value"> </el-option>
          </el-select>
          <el-button type="primary" v-preventReClick class="search" icon="el-icon-search" @click="getStaffmanagementItem">検索</el-button>
        </div>
        <div class="searchDivRight">
          <el-button type="primary" v-preventReClick icon="el-icon-plus" @click="addClick">新規</el-button>
          <!-- <el-button type="warning" icon="el-icon-edit" @click="addEdit">修正</el-button>
          <el-button type="danger" icon="el-icon-delete" @click="remove">離職</el-button>
          <el-button type="success" icon="el-icon-share" @click="chushihuamima">パスワード初期化</el-button> -->
          <!-- <el-button type="danger" icon="el-icon-key" @click="huoququanxian">権限</el-button> -->
        </div>
      </div>

      <!-- 表格操作 -->
      <el-table :data="tableDataList" border class="tableSet1" :header-cell-style="{ background: '#f2f2f2', color: '#606266' }">
        <!-- <el-table-column type="selection" width="55"> </el-table-column> -->
        <!-- <el-table-column fixed prop="enterpriseName" label="会社名称" width="220"> </el-table-column> -->
        <el-table-column fixed prop="userNo" label="社員番号" width="100"> </el-table-column>
        <el-table-column fixed prop="userName" label="名前" width="130"> </el-table-column>
        <el-table-column prop="departName" label="部門" width="180"> </el-table-column>
        <el-table-column prop="roleName" label="職務" width="180"> </el-table-column>
        <el-table-column prop="tel1" label="連絡先１" width="120"> </el-table-column>
        <el-table-column prop="tel2" label="連絡先２" width="120"> </el-table-column>
        <el-table-column prop="email" label="メールアドレス" width="180"> </el-table-column>
        <el-table-column prop="origo" label="本籍" width="120"> </el-table-column>
        <el-table-column prop="sex" label="性別" width="100"> </el-table-column>
        <el-table-column prop="educationName" label="学歴" width="150"> </el-table-column>
        <el-table-column prop="graduationTime" label="卒業時間" width="110"> </el-table-column>
        <el-table-column prop="idCar" label="身分証明書" width="180"> </el-table-column>
        <el-table-column prop="workYear" label="勤務年数" width="100"> </el-table-column>
        <el-table-column prop="softYear" label="ソフトウェア業界の勤続年数" width="210"> </el-table-column>
        <el-table-column prop="hiredate" label="入職時間" width="110"> </el-table-column>
        <el-table-column fixed="right" label="アクション" width="390" align="center">
          <template #default="scope">
            <el-button type="warning" v-preventReClick icon="el-icon-edit" @click="addEdit(scope.row)">修正</el-button>
            <el-button type="danger" v-preventReClick icon="el-icon-delete" @click="remove(scope.row.userinfoGuid)">離職</el-button>
            <el-button type="success" v-preventReClick icon="el-icon-share" @click="chushihuamima(scope.row.userinfoGuid)">パスワード初期化</el-button>
          </template>
        </el-table-column>
      </el-table>

      <!-- 分页功能 -->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="staffmanagement.indexPage"
        :page-size="staffmanagement.pageSize"
        layout="total, prev, pager, next, jumper"
        :total="total"
        style="text-align: center"
      >
      </el-pagination>

      <!-- 新增对话框 -->
      <el-dialog title="社員情報新規" v-model="dialogVisible" width="750px" @close="resetForm" destroy-on-close>
        <el-form :model="addForm" :rules="rules" ref="addForm">
          <table class="mytable" cellpadding="0" cellspacing="0" :model="table" :rules="rules">
            <colgroup>
              <col style="width: 20%" />
              <col style="width: 30%" />
              <col style="width: 20%" />
              <col style="width: 30%" />
            </colgroup>

            <tr class="mytr">
              <td class="mytd">会社の名前</td>
              <td class="mytd1">
                <el-select v-model="addForm.groupEnterpriseGuid" placeholder="" style="border: 0" class="paperview-input-text">
                  <el-option v-for="item in optionData1.value" :key="item.value" :label="item.name" :value="item.value"> </el-option>
                </el-select>
              </td>
              <td class="mytd">部門名称</td>
              <td class="mytd1">
                <el-select v-model="addForm.departGuid" placeholder="" class="paperview-input-text">
                  <el-option v-for="item in optionData1.value1[addForm.groupEnterpriseGuid]" :key="item.value" :label="item.name" :value="item.value"> </el-option>
                </el-select>
              </td>
            </tr>

            <tr class="mytr">
              <td class="mytd"><span style="color: red; font-size: 15px">*</span>&nbsp;社員番号</td>
              <td class="mytd1">
                <el-input maxlength="20" id="user_no" v-model="addForm.userNo" placeholder="" class="paperview-input-text"> </el-input>
              </td>
              <td class="mytd">管理員か否か</td>
              <td class="mytd1">
                &nbsp;&nbsp;&nbsp;
                <el-switch v-model="addForm.flag" class="demo" active-color="#00A854" active-text="はい" active-value="0" inactive-color="#F04134" inactive-text="いいえ" inactive-value="1">
                </el-switch>
              </td>
            </tr>
            <tr class="mytr">
              <td class="mytd"><span style="color: red; font-size: 15px">*</span>&nbsp;パスワード</td>
              <td class="mytd1" colspan="3">
                <el-input maxlength="32" v-model="addForm.pwd" placeholder="" style="width: auto" class="paperview-input-text"></el-input>
                &nbsp;
                <el-button @click="createpwd1">{{ ruleForm.button1 }}</el-button>
                <el-button @click="createpwd2">{{ ruleForm.button2 }}</el-button>
                <el-button @click="createpwd3">{{ ruleForm.button3 }}</el-button>
              </td>
            </tr>
            <tr class="mytr">
              <td class="mytd"><span style="color: red; font-size: 15px">*</span>&nbsp;名前</td>
              <td class="mytd1">
                <el-input maxlength="10" v-model="addForm.userName" placeholder="" class="paperview-input-text"></el-input>
              </td>
              <td class="mytd"><span style="color: red; font-size: 15px">*</span>&nbsp;本籍</td>
              <td class="mytd1">
                <el-input maxlength="10" v-model="addForm.origo" placeholder="" class="paperview-input-text"></el-input>
              </td>
            </tr>

            <tr class="mytr">
              <td class="mytd">性別</td>
              <td class="mytd1">
                &nbsp;&nbsp;&nbsp;
                <el-radio v-model="addForm.sex" label="1">男</el-radio>
                <el-radio v-model="addForm.sex" label="2">女</el-radio>
              </td>
              <td class="mytd"><span style="color: red; font-size: 15px">*</span>&nbsp;学歴</td>
              <td class="mytd1">
                <el-select v-model="addForm.education" placeholder="" class="paperview-input-text">
                  <el-option v-for="item in optionData1.value3" :key="item.value" :label="item.name" :value="item.value"> </el-option>
                </el-select>
              </td>
            </tr>

            <tr class="mytr">
              <td class="mytd">職務</td>
              <td class="mytd1">
                <el-select v-model="addForm.roleGuid" placeholder="" class="paperview-input-text">
                  <el-option v-for="item in optionData1.value2[addForm.groupEnterpriseGuid]" :key="item.value" :label="item.name" :value="item.value"> </el-option>
                </el-select>
              </td>
              <td class="mytd"><span style="color: red; font-size: 15px">*</span>&nbsp;卒業時間</td>
              <td class="mytd1">
                <el-date-picker v-model="addForm.graduationTime" type="date" placeholder="" format="YYYY-MM-DD" value-format="YYYY-MM-DD" class="paperview-input-text"> </el-date-picker>
              </td>
            </tr>

            <tr class="mytr">
              <td class="mytd"><span style="color: red; font-size: 15px">*</span>&nbsp;連絡先1</td>
              <td class="mytd1">
                <el-input maxlength="20" v-model="addForm.tel1" placeholder="" class="paperview-input-text"></el-input>
              </td>
              <td class="mytd">連絡先2</td>
              <td class="mytd1">
                <el-input maxlength="20" v-model="addForm.tel2" placeholder="" class="paperview-input-text"></el-input>
              </td>
            </tr>

            <tr class="mytr">
              <td class="mytd"><span style="color: red; font-size: 15px">*</span>&nbsp;身分証明書番号</td>
              <td class="mytd1">
                <el-input maxlength="19" v-model="addForm.idCar" placeholder="" class="paperview-input-text"></el-input>
              </td>
              <td class="mytd"><span style="color: red; font-size: 15px">*</span>&nbsp;入職時間</td>
              <td class="mytd1">
                <el-date-picker v-model="addForm.hiredate" type="date" placeholder="" format="YYYY-MM-DD" value-format="YYYY-MM-DD" class="paperview-input-text"> </el-date-picker>
              </td>
            </tr>

            <tr class="mytr">
              <td class="mytd"><span style="color: red; font-size: 15px">*</span>&nbsp;勤続年数</td>
              <td class="mytd1">
                <el-input maxlength="3" v-model="addForm.workYear" placeholder="" class="paperview-input-text"></el-input>
              </td>
              <td class="mytd"><span style="color: red; font-size: 15px">*</span>&nbsp;ソフトウェア業界の勤続年数</td>
              <td class="mytd1">
                <el-input maxlength="3" v-model="addForm.softYear" placeholder="" class="paperview-input-text"></el-input>
              </td>
            </tr>

            <tr class="mytr">
              <td class="mytd"><span style="color: red; font-size: 15px">*</span>&nbsp;メールアドレス</td>
              <td class="mytd1">
                <el-input maxlength="50" v-model="addForm.email" placeholder="" class="paperview-input-text"></el-input>
              </td>
              <td class="mytd">すべての審査見えるか否か</td>
              <td class="mytd1">
                &nbsp;&nbsp;&nbsp;
                <el-switch v-model="addForm.selectFlag" class="demo" active-color="#00A854" active-text="はい" active-value="0" inactive-color="#F04134" inactive-text="いいえ" inactive-value="1">
                </el-switch>
              </td>
            </tr>

            <tr class="mytr">
              <td class="mytd">メモ</td>
              <td class="mytd1" colspan="3">
                <el-input maxlength="50" type="textarea" :autosize="{ minRows: 2, maxRows: 6 }" placeholder="" v-model="addForm.make" class="paperview-input-text1"> </el-input>
              </td>
            </tr>
          </table>
        </el-form>
        <br />
        <br />
        <div style="width: 100%; text-align: center">
          <!-- <el-button @click="dialogVisible = false">取 消</el-button> -->
          <el-button type="primary" @click="saveSchdule" icon="el-icon-circle-check" v-preventReClick> 保存 </el-button>
        </div>
      </el-dialog>

      <!-- 编辑对话框 -->
      <el-dialog title="社員情報編集" v-model="dialogVisible1" width="750px">
        <el-form :model="bianjiForm" :rules="rules" ref="editruleForm">
          <table class="mytable" cellpadding="0" cellspacing="0">
            <colgroup>
              <col style="width: 20%" />
              <col style="width: 30%" />
              <col style="width: 20%" />
              <col style="width: 30%" />
            </colgroup>
            <tr class="mytr">
              <td class="mytd">会社の名前</td>
              <td class="mytd1">
                <el-select v-model="bianjiForm.groupEnterpriseGuid" placeholder="" style="border: 0" class="paperview-input-text">
                  <el-option v-for="item in optionData1.value" :key="item.value" :label="item.name" :value="item.value"> </el-option>
                </el-select>
              </td>
              <td class="mytd">部門名称</td>
              <td class="mytd1">
                <el-select v-model="bianjiForm.departGuid" placeholder="" class="paperview-input-text">
                  <el-option v-for="item in optionData1.value1[bianjiForm.groupEnterpriseGuid]" :key="item.value" :label="item.name" :value="item.value"> </el-option>
                </el-select>
              </td>
            </tr>

            <tr class="mytr">
              <td class="mytd"><span style="color: red; font-size: 15px">*</span>&nbsp;社員番号</td>
              <td class="mytd1">
                <el-input id="user_no" v-model="bianjiForm.userNo" placeholder="" class="paperview-input-text"> </el-input>
              </td>
              <td class="mytd">管理員か否か</td>
              <td class="mytd1">
                &nbsp;&nbsp;&nbsp;
                <el-switch v-model="bianjiForm.flag" class="demo" active-color="#00A854" active-text="はい" active-value="0" inactive-color="#F04134" inactive-text="いいえ" inactive-value="1">
                </el-switch>
              </td>
            </tr>

            <!-- <tr class="mytr">
              <td class="mytd"><span style="color: red; font-size: 15px;">*</span>&nbsp;パスワード</td>
              <td class="mytd1" colspan="3">
                <el-input v-model="bianjiForm.pwd" placeholder="" style="width: auto;" class="paperview-input-text"></el-input>
                &nbsp;
                <el-button @click="createpwd1" v-model="ruleForm.button1">{{ ruleForm.button1 }}</el-button>
                <el-button @click="createpwd2" v-model="ruleForm.button2">{{ ruleForm.button2 }}</el-button>
                <el-button @click="createpwd3" v-model="ruleForm.button3">{{ ruleForm.button3 }}</el-button>
              </td>
            </tr> -->

            <tr class="mytr">
              <td class="mytd"><span style="color: red; font-size: 15px">*</span>&nbsp;名前</td>
              <td class="mytd1">
                <el-input maxlength="10" v-model="bianjiForm.userName" placeholder="" class="paperview-input-text"></el-input>
              </td>
              <td class="mytd"><span style="color: red; font-size: 15px">*</span>&nbsp;本籍</td>
              <td class="mytd1">
                <el-input maxlength="10" v-model="bianjiForm.origo" placeholder="" class="paperview-input-text"></el-input>
              </td>
            </tr>

            <tr class="mytr">
              <td class="mytd">性別</td>
              <td class="mytd1">
                &nbsp;&nbsp;&nbsp;
                <el-radio v-model="bianjiForm.sex" label="1">男</el-radio>
                <el-radio v-model="bianjiForm.sex" label="2">女</el-radio>
              </td>
              <td class="mytd"><span style="color: red; font-size: 15px">*</span>&nbsp;学歴</td>
              <td class="mytd1">
                <el-select v-model="bianjiForm.education" placeholder="" class="paperview-input-text">
                  <el-option v-for="item in optionData1.value3" :key="item.value" :label="item.name" :value="item.value"> </el-option>
                </el-select>
              </td>
            </tr>

            <tr class="mytr">
              <td class="mytd">職務</td>
              <td class="mytd1">
                <el-select v-model="bianjiForm.roleGuid" placeholder="" class="paperview-input-text">
                  <el-option v-for="item in optionData1.value2[bianjiForm.groupEnterpriseGuid]" :key="item.value" :label="item.name" :value="item.value"> </el-option>
                </el-select>
              </td>
              <td class="mytd"><span style="color: red; font-size: 15px">*</span>&nbsp;卒業時間</td>
              <td class="mytd1">
                <el-date-picker v-model="bianjiForm.graduationTime" type="date" placeholder="" format="YYYY-MM-DD" value-format="YYYY-MM-DD" class="paperview-input-text"> </el-date-picker>
              </td>
            </tr>

            <tr class="mytr">
              <td class="mytd"><span style="color: red; font-size: 15px">*</span>&nbsp;連絡先１</td>
              <td class="mytd1">
                <el-input maxlength="20" v-model="bianjiForm.tel1" placeholder="" class="paperview-input-text"></el-input>
              </td>
              <td class="mytd">連絡先２</td>
              <td class="mytd1">
                <el-input maxlength="20" v-model="bianjiForm.tel2" placeholder="" class="paperview-input-text"></el-input>
              </td>
            </tr>

            <tr class="mytr">
              <td class="mytd"><span style="color: red; font-size: 15px">*</span>&nbsp;身分証明書番号</td>
              <td class="mytd1">
                <el-input maxlength="19" v-model="bianjiForm.idCar" placeholder="" class="paperview-input-text"></el-input>
              </td>
              <td class="mytd"><span style="color: red; font-size: 15px">*</span>&nbsp;入職時間</td>
              <td class="mytd1">
                <el-date-picker v-model="bianjiForm.hiredate" type="date" placeholder="" format="YYYY-MM-DD" value-format="YYYY-MM-DD" class="paperview-input-text"> </el-date-picker>
              </td>
            </tr>

            <tr class="mytr">
              <td class="mytd"><span style="color: red; font-size: 15px">*</span>&nbsp;勤続年数</td>
              <td class="mytd1">
                <el-input maxlength="3" v-model="bianjiForm.workYear" placeholder="" class="paperview-input-text"></el-input>
              </td>
              <td class="mytd"><span style="color: red; font-size: 15px">*</span>&nbsp;ソフトウェア業界の勤続年数</td>
              <td class="mytd1">
                <el-input maxlength="3" v-model="bianjiForm.softYear" placeholder="" class="paperview-input-text"></el-input>
              </td>
            </tr>

            <tr class="mytr">
              <td class="mytd"><span style="color: red; font-size: 15px">*</span>&nbsp;メールアドレス</td>
              <td class="mytd1">
                <el-input maxlength="50" v-model="bianjiForm.email" placeholder="" class="paperview-input-text"></el-input>
              </td>
              <td class="mytd">すべての審査見えるか否か</td>
              <td class="mytd1">
                &nbsp;&nbsp;&nbsp;
                <el-switch v-model="bianjiForm.selectFlag" class="demo" active-color="#00A854" active-text="はい" active-value="0" inactive-color="#F04134" inactive-text="いいえ" inactive-value="1">
                </el-switch>
              </td>
            </tr>

            <tr class="mytr">
              <td class="mytd">メモ</td>
              <td class="mytd1" colspan="3">
                <el-input maxlength="50" type="textarea" :autosize="{ minRows: 2, maxRows: 6 }" placeholder="" v-model="bianjiForm.make" class="paperview-input-text1"> </el-input>
              </td>
            </tr>
          </table>
        </el-form>
        <br />
        <br />
        <div style="width: 100%; text-align: center">
          <el-button type="primary" @click="updata" icon="el-icon-circle-check" v-preventReClick>保存 </el-button>
        </div>
      </el-dialog>
    </el-card>
  </div>
</template>


<script>
export default {
  data() {
    return {
      // 刪除數據id數組
      removeID: {
        ids: []
      },
      //新增表单
      addForm: {
        groupEnterpriseGuid: '',
        departGuid: '',
        userNo: '',
        pwd: '',
        userName: '',
        origo: '',
        sex: '',
        education: '',
        roleGuid: '',
        graduationTime: '',
        tel1: '',
        tel2: '',
        idCar: '',
        hiredate: '',
        email: '',
        make: '',
        flag: '',
        deleteFlag: '1',
        authority: '',
        workYear: '',
        softYear: '',
        selectFlag: ''
      },
      addFormCopy: {
        groupEnterpriseGuid: '',
        departGuid: '',
        userNo: '',
        pwd: '',
        userName: '',
        origo: '',
        sex: '',
        education: '',
        roleGuid: '',
        graduationTime: '',
        tel1: '',
        tel2: '',
        idCar: '',
        hiredate: '',
        email: '',
        make: '',
        flag: '',
        deleteFlag: '1',
        authority: '',
        workYear: '',
        softYear: '',
        selectFlag: ''
      },
      //编辑表单
      bianjiForm: {
        userinfoGuid: '',
        groupEnterpriseGuid: '',
        departGuid: '',
        userNo: '',
        // pwd: '',
        userName: '',
        origo: '',
        sex: '',
        education: '',
        roleGuid: '',
        graduationTime: '',
        tel1: '',
        tel2: '',
        idCar: '',
        hiredate: '',
        email: '',
        make: '',
        flag: '',
        deleteFlag: '1',
        authority: '',
        workYear: '',
        softYear: '',
        keyApp: '1',
        keyPc: 'd718dcde69b54059839208d6d2b1d6d3',
        selectFlag: ''
      },
      //获取过来的所有员工管理数据
      tableDataList: [],
      total: 0,
      //查询所用数据
      staffmanagement: {
        indexPage: 1,
        pageSize: 8,
        searchbean: {
          groupEnterpriseGuid: this.$store.getters.showentergroup,
          departGuid: '',
          userNo: '',
          userName: '',
          roleGuid: ''
        }
      },
      // 复选框的数组
      multipleSelection: [],
      optionData: {
        value: [
          {
            value: '',
            name: '全部'
          }
        ],
        value1: {
          全部: [
            {
              value: '',
              name: ''
            }
          ]
        },
        value2: {
          全部: [
            {
              value: '',
              name: ''
            }
          ]
        }
      },
      //增加
      optionData1: {
        value: [],
        value1: {},
        value2: {},
        //学历
        value3: []
      },
      // 新增对话框
      dialogVisible: false,
      // 编辑对话框
      dialogVisible1: false,
      // id
      id: {
        userinfoGuid: ''
      },
      // 新增对话框数据
      ruleForm: {
        button1: '111111',
        button2: '123456',
        button3: 'ランダム六桁'
      }
    }
  },
  // 頁面初加載
  created() {
    this.getStaffmanagementItem()
    this.getCheckedNodes()
  },
  methods: {
    getCheckedNodes() {
      // 聲明對象
      function ObjStory(value, name) {
        this.value = value
        this.name = name
      }
      this.axios.post('/userInfo/insert/info').then((res) => {
        var enterprise = res.data.data.groupEnterpriseVos
        var education = res.data.data.educations
        enterprise.forEach((item) => {
          const ls = item.groupEnterpriseGuid
          // console.log(enterprise);
          this.optionData.value1[ls] = [
            {
              value: '',
              name: '全部'
            }
          ],
            //增加
            this.optionData1.value1[ls] = [],
            // 职务
            this.optionData.value2[ls] = [
              {
                value: '',
                name: '全部'
              }
            ],
            //增加
            this.optionData1.value2[ls] = [],
            this.optionData.value.push(new ObjStory(item.groupEnterpriseGuid, item.enterpriseName))

          //增加
          this.optionData1.value.push(new ObjStory(item.groupEnterpriseGuid, item.enterpriseName))

          item.departments.forEach((item1) => {
            this.optionData.value1[ls].push(new ObjStory(item1.departGuid, item1.departName))
          })

          //增加
          item.departments.forEach((item1) => {
            this.optionData1.value1[ls].push(new ObjStory(item1.departGuid, item1.departName))
          })

          // 职务
          item.roles.forEach((item1) => {
            this.optionData.value2[ls].push(new ObjStory(item1.roleGuid, item1.roleName))
          })

          //增加
          item.roles.forEach((item1) => {
            this.optionData1.value2[ls].push(new ObjStory(item1.roleGuid, item1.roleName))
          })
        })

        //学历
        education.forEach((item) => {
          this.optionData1.value3.push(new ObjStory(item.educationGuid, item.educationName))
        })
      })
    },
    // 监听 pagesize 改变的事件
    handleSizeChange(newSize) {
      // console.log(newSize)
      this.staffmanagement.pageSize = newSize
      this.getStaffmanagementItem()
    },
    // 监听 页码值 改变的事件
    handleCurrentChange(newPage) {
      this.staffmanagement.indexPage = newPage
      this.getStaffmanagementItem()
    },
    // 分頁查詢數據
    getStaffmanagementItem() {
      this.axios
        .post('/userInfo/listUserInfo', this.staffmanagement)
        .then((res) => {
          this.tableDataList = res.data.data.list
          //性别1男 2女
          for (var i = 0; i < this.tableDataList.length; i++) {
            this.tableDataList[i].hiredate = this.tableDataList[i].hiredate.substring(0, 10)
            this.tableDataList[i].graduationTime = this.tableDataList[i].graduationTime.substring(0, 10)
            if (this.tableDataList[i].sex == '1') {
              this.tableDataList[i].sex = '男'
            } else {
              this.tableDataList[i].sex = '女'
            }
          }
          this.total = res.data.data.total
        })
        .catch((error) => {
          console.log(error)
        })
    },
    // 新增员工管理信息
    async saveSchdule() {
      // 新增员工管理请求
      console.log(typeof this.addForm.groupEnterpriseGuid)
      if (this.addForm.groupEnterpriseGuid === '') {
        return this.$message.error('会社の名前が空できません')
      }
      if (this.addForm.userNo === '') {
        return this.$message.error('社員番号が空できません')
      }

      if (this.addForm.pwd === '') {
        return this.$message.error('パスワードが空できません')
      }

      if (this.addForm.userName === '') {
        return this.$message.error('名前が空できません')
      }

      if (this.addForm.origo === '') {
        return this.$message.error('本籍が空できません')
      }

      if (this.addForm.graduationTime === '') {
        return this.$message.error('卒業時間が空できません')
      }

      if (this.addForm.tel1 === '') {
        return this.$message.error('連絡先1が空できません')
      }

      if (this.addForm.idCar === '') {
        return this.$message.error('身分証明書が空できません')
      }

      if (this.addForm.hiredate === '') {
        return this.$message.error('入職時間が空できません')
      }

      if (this.addForm.workYear === '') {
        return this.$message.error('勤続年数が空できません')
      }

      if (this.addForm.softYear === '') {
        return this.$message.error('ソフト歴が空できません')
      }

      if (this.addForm.email === '') {
        return this.$message.error('メールが空できません')
      }

      console.log(typeof this.addForm.flag)
      console.log(this.addForm.selectFlag)
      if (this.addForm.flag === '0') {
        this.addForm.flag = '0'
      } else {
        this.addForm.flag = '1'
      }
      if (this.addForm.selectFlag === '0') {
        this.addForm.selectFlag = '0'
      } else {
        this.addForm.selectFlag = '1'
      }
      console.log(this.addForm)
      this.axios
        .post('userInfo/insert', this.addForm)
        .then((res) => {
          if (res.data.success !== 1) return this.$message.error(res.data.msg)
          this.$message.success(this.$getMsg('I0001'))
          this.dialogVisible = false
          this.getStaffmanagementItem()
        })
        .catch((error) => {
          console.log(error)
        })
    },

    // 刪除员工管理信息
    remove(id) {
      this.removeID.ids.push(id)
      this.axios
        .delete('/userInfo/deleteById', {
          data: this.removeID
        })
        .then((res) => {
          this.$message.success(this.$getMsg('I0003'))
          this.getStaffmanagementItem()
        })
        .catch((error) => {
          console.log(error)
        })
    },
    createpwd1() {
      this.addForm.pwd = this.ruleForm.button1
    },
    createpwd2() {
      this.addForm.pwd = this.ruleForm.button2
    },
    createpwd3() {
      let num = ''
      for (let i = 0; i < 6; i++) {
        num += Math.floor(Math.random() * 10)
      }
      this.addForm.pwd = num
    },
    // 编辑员工管理信息
    addEdit(userInfo) {
      this.multipleSelection.push(userInfo)
      console.log(userInfo)
      this.id.userinfoGuid = userInfo.userinfoGuid
      this.axios
        .post('/userInfo/getUserById', this.id)
        .then((res) => {
          const tableData = res.data.data
          console.log(tableData)
          if (tableData.flag === '0') {
            this.bianjiForm.flag = '0'
          } else {
            this.bianjiForm.flag = '1'
          }
          if (tableData.selectFlag === '0') {
            this.bianjiForm.selectFlag = '0'
          } else {
            this.bianjiForm.selectFlag = '1'
          }
          console.log(this.bianjiForm.flag)
          this.bianjiForm.groupEnterpriseGuid = tableData.groupEnterpriseGuid
          this.bianjiForm.departGuid = tableData.departGuid
          this.bianjiForm.roleGuid = tableData.roleGuid
          this.bianjiForm.userNo = tableData.userNo
          // this.bianjiForm.pwd = tableData.pwd
          this.bianjiForm.userName = tableData.userName
          this.bianjiForm.origo = tableData.origo
          this.bianjiForm.sex = tableData.sex
          this.bianjiForm.education = tableData.education
          this.bianjiForm.graduationTime = tableData.graduationTime
          this.bianjiForm.tel1 = tableData.tel1
          this.bianjiForm.tel2 = tableData.tel2
          this.bianjiForm.idCar = tableData.idCar
          this.bianjiForm.hiredate = tableData.hiredate
          this.bianjiForm.workYear = tableData.workYear
          this.bianjiForm.softYear = tableData.softYear
          this.bianjiForm.email = tableData.email
          this.bianjiForm.make = tableData.make
          this.dialogVisible1 = true
        })
        .catch((error) => {
          console.log(error)
        })
    },

    // 更新修改员工管理信息
    updata() {
      this.multipleSelection.forEach((item) => {
        this.bianjiForm.userinfoGuid = item.userinfoGuid
        if (this.bianjiForm.flag === '0') {
          this.bianjiForm.flag = '0'
        } else {
          this.bianjiForm.flag = '1'
        }
        if (this.bianjiForm.selectFlag === '0') {
          this.bianjiForm.selectFlag = '0'
        } else {
          this.bianjiForm.selectFlag = '1'
        }
        this.bianjiForm.graduationTime = this.bianjiForm.graduationTime.substring(0, 10)
        this.bianjiForm.hiredate = this.bianjiForm.hiredate.substring(0, 10)
      })
      if (this.bianjiForm.groupEnterpriseGuid === '') {
        return this.$message.error('会社の名前が空できません')
      }
      if (this.bianjiForm.userNo === '') {
        return this.$message.error('社員番号が空できません')
      }

      // if (this.bianjiForm.pwd === '') {
      //   return this.$message.error('パスワードが空できません')
      // }

      if (this.bianjiForm.userName === '') {
        return this.$message.error('名前が空できません')
      }

      if (this.bianjiForm.origo === '') {
        return this.$message.error('本籍が空できません')
      }
      if (this.bianjiForm.graduationTime === '') {
        return this.$message.error('卒業時間が空できません')
      }

      if (this.bianjiForm.tel1 === '') {
        return this.$message.error('連絡先1が空できません')
      }

      if (this.bianjiForm.idCar === '') {
        return this.$message.error('身分証明書が空できません')
      }

      if (this.bianjiForm.hiredate === '') {
        return this.$message.error('入職時間が空できません')
      }

      if (this.bianjiForm.workYear === '') {
        return this.$message.error('勤続年数が空できません')
      }

      if (this.bianjiForm.softYear === '') {
        return this.$message.error('ソフト歴が空できません')
      }

      if (this.bianjiForm.email === '') {
        return this.$message.error('メールが空できません')
      }

      this.axios
        .post('/userInfo/update', this.bianjiForm)
        .then((res) => {
          if (res.data.success !== 1) return this.$message.error(res.data.msg)
          this.$message.success(this.$getMsg('I0002'))
          this.dialogVisible1 = false
          this.getStaffmanagementItem()
        })
        .catch((error) => {
          console.log(error)
        })
    },
    // 初始化密码编辑
    chushihuamima(id) {
      this.$confirm('本当にパスワードを初期化しますか？', 'パスワードをリセット', {
        cancelButtonText: 'キャンセル',
        confirmButtonText: '確認',
        type: 'warning'
      }).then(() => {
        this.removeID.ids.push(id)
        this.axios
          .post('/userInfo/resetpassword', {
            ids: this.removeID.ids
          })
          .then((res) => {
            if (res.data.success !== 1) return this.$message.error(res.data.msg)
            this.$message.success(this.$getMsg('I0002'))
            this.getStaffmanagementItem()
          })
          .catch((error) => {
            console.log(error)
          })
      },
      (res)=>{
        console.log(res)
      })
    },
    //三级下拉列表联动
    change1: function (val) {
      if (val) {
        this.staffmanagement.searchbean.departGuid = this.optionData.value1[val][0].value
        this.staffmanagement.searchbean.roleGuid = this.optionData.value2[val][0].value
      } else {
        this.staffmanagement.searchbean.departGuid = ''
        this.staffmanagement.searchbean.roleGuid = ''
      }
    },
    // 追加弹出框的数据初始化
    resetForm() {
      this.$nextTick(() => {
        this.addForm = this.addFormCopy
      })
    },
    handleClose() {},
    addClick(){
      this.dialogVisible = true
      this.addForm.groupEnterpriseGuid = this.optionData1.value[0].value

      console.log(this.optionData1.value1);
      this.addForm.departGuid = this.optionData1.value1[this.addForm.groupEnterpriseGuid][0].value
      this.addForm.sex = '1'
      this.addForm.education = this.optionData1.value3[0].value

      this.addForm.roleGuid = this.optionData1.value2[this.addForm.groupEnterpriseGuid][0].value
    }
  }
}
</script>

<style scoped>
#staffmanagement_container .paperview-input-text .el-input__inner {
  -webkit-appearance: none;
  background-color: #fff;
  background-image: none;
  border-radius: 4px;
  border: 0 !important;
  width: 100%;
}

.paperview-input-text1 .el-textarea__inner {
  border: 0 !important;
  resize: none !important;
}

/* 新增滑动开关样式设置 */
.demo .el-switch__label {
  position: absolute;
  display: none;
  color: #ffffff;
}

/*打开时文字位置设置*/
.demo .el-switch__label--right {
  z-index: 1;
  right: -3px;
}

/*关闭时文字位置设置*/
.demo .el-switch__label--left {
  z-index: 1;
  left: 18px;
}

/*显示文字*/
.demo .el-switch__label.is-active {
  display: block;
  color: white;
}

.demo.el-switch .el-switch__core,
.el-switch .el-switch__label {
  width: 60px !important;
}

.tableSet1 {
  height: auto !important;
}

.demo .el-switch .el-switch__core,
.el-switch .el-switch__label {
  width: 50px !important;
}
.departGuid {
  width: 285px;
}
.userName {
  width: 100px;
}
.userNo {
  width: 100px;
}
.roleGuid {
  width: 270px;
}
</style>
